export var scoket = window.io();
scoket.$on = function (cb) {
    scoket.on("chat message", cb);
};
scoket.$emit = function (data) {
    scoket.emit("chat message", data);
};
var onQueue = [];
scoket.on("chat message", function (res) {
    onQueue.forEach(function (on) {
        if (on.path === res.path && (on.role === res.role || on.role === "*")) {
            on.cb({ role: on.role, path: on.path, value: res.value });
        }
    });
});
export var on = {
    p1: function (path, cb) {
        onQueue.push({ role: "p1", path: path, cb: cb });
    },
    p2: function (path, cb) {
        onQueue.push({ role: "p2", path: path, cb: cb });
    },
    all: function (path, cb) {
        onQueue.push({ role: "*", path: path, cb: cb });
    }
};
//#endregion
export var emit = {
    p1: function (path, value) {
        scoket.emit("chat message", { role: "p1", path: path, value: value });
    },
    p2: function (path, value) {
        scoket.emit("chat message", { role: "p2", path: path, value: value });
    },
    all: function (role, path, value) {
        scoket.$emit({ role: role, path: path, value: value });
    }
};
